function[I2]=jpeg_color(nomfich,q_jpeg)
    if q_jpeg >= 1 && q_jpeg <= 50
        alpha = 50/q_jpeg;
    elseif q_jpeg >= 50 && q_jpeg <= 99
        alpha = 2-(2*q_jpeg/100);
    end


    Q=[16 11 10 16 24 40 51 61;
       12 12 14 19 26 58 60 55;
       14 13 16 24 40 57 69 56;
       14 17 22 29 51 87 80 62;
       18 22 37 56 68 109 103 77;
       24 35 55 64 81 104 113 92;
       49 64 78 87 103 121 120 101;
       72 92 95 98 112 100 103 99];


    A=imread(nomfich);
    Ir=double(A(:,:,1))-128;
    Ib=double(A(:,:,2))-128;
    Ig=double(A(:,:,3))-128;

    Q = alpha*Q;

    Br=blkproc(Ir,[8 8],'dct2(x)'); 
    B1r=fix(blkproc(Br,[8 8],'x./P1',Q));
    B2r=fix(blkproc(B1r,[8 8],'x.*P1',Q));
    I2(:,:,1)=blkproc(B2r,[8 8],'idct2(x)');
    
    Bb=blkproc(Ib,[8 8],'dct2(x)'); 
    B1b=fix(blkproc(Bb,[8 8],'x./P1',Q));
    B2b=fix(blkproc(B1b,[8 8],'x.*P1',Q));
    I2(:,:,2)=blkproc(B2b,[8 8],'idct2(x)');
    
    Bg=blkproc(Ig,[8 8],'dct2(x)'); 
    B1g=fix(blkproc(Bg,[8 8],'x./P1',Q));
    B2g=fix(blkproc(B1g,[8 8],'x.*P1',Q));
    I2(:,:,3)=blkproc(B2g,[8 8],'idct2(x)');
    
    I2=uint8(128+I2);
    imshow(A),figure,imshow(I2);

   
    